package com.hongyue.day01;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Demo {
    public static void main(String[] args) {
        String[] hua = {"♥","♠","♣","♦"};
        String[] zi = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        ArrayList<String> arr = new ArrayList<>();
        for (int i = 0; i < hua.length; i++) {
            for (int j = 0; j < zi.length; j++) {
                arr.add(hua[i] + zi[j]);
            }
        }
        arr.add("joker");
        arr.add("JOKER");
        arr.add("癞子");
        Collections.shuffle(arr);
        ArrayList<String> 周润发 = new ArrayList<>();
        ArrayList<String> 周星驰 = new ArrayList<>();
        ArrayList<String> 刘德华 = new ArrayList<>();
        ArrayList<String> 底牌 = new ArrayList<>();
        底牌.add(arr.get(arr.size()-1));
        底牌.add(arr.get(arr.size()-2));
        底牌.add(arr.get(arr.size()-3));
        底牌.add(arr.get(arr.size()-4));
        for (int i = 0; i < arr.size() - 4; i++) {
            if (i % 3 == 0) {
                周润发.add(arr.get(i));
            } else if (i % 3 == 1) {
                周星驰.add(arr.get(i));
            } else if (i % 3 == 2) {
                刘德华.add(arr.get(i));
            }
        }
        String a = "34567891JQKA2oO子";
        Collections.sort(周润发, getC(a));
        Collections.sort(周星驰, getC(a));
        Collections.sort(刘德华, getC(a));
        Collections.sort(底牌, getC(a));
        System.out.println("刘德华 = " + 刘德华);
        System.out.println("周星驰 = " + 周星驰);
        System.out.println("周润发 = " + 周润发);
        System.out.println("底牌 = " + 底牌);
    }

    private static Comparator<String> getC(String a) {
        return (o1, o2) -> a.indexOf(o1.charAt(1)) - a.indexOf(o2.charAt(1));
    }
}
